package com.masterclient.app.modules.goods.contract;

import com.eoner.baselib.presenter.ThrowableConsumer;
import com.eoner.managerlibrary.netsign.NetEnvManager;
import com.masterclient.app.httpservice.RetrofitUtil;
import com.eoner.baselibrary.bean.goods.GoodsCommentBean;

import io.reactivex.Observable;
import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;

/**
* Created by TMVPHelper on 2017/08/21
*/
public class AllCommentPresenter extends AllCommentContract.Presenter{

    @Override
    public void getCommentList(String is_image, String page, String page_size, String product_id) {
        Observable<GoodsCommentBean> observable = RetrofitUtil.getInstance().getCommentGoodsList(NetEnvManager.BASE_SURL+"1/product/get_product_review/product_id_"+product_id+"/"+page+"-"+page_size+".html");

        Disposable disposable = toSubscribe(observable, new Consumer<GoodsCommentBean>() {
            @Override
            public void accept(@NonNull GoodsCommentBean bean) throws Exception {
                if("0".equals(bean.getCode())){
                    mView.showGoodsComment(bean.getData());
                }
            }
        }, new ThrowableConsumer());
        mRxManager.add(disposable);
    }
}